package com.lange.fileManagement.service;

import com.alibaba.fastjson.JSONObject;
import com.lange.fileManagement.dao.BaseDaoImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class BaseService {

    @Autowired
    private BaseDaoImpl baseDaoImpl;


    /*动态根据表明获取表的所有信息*/
    public List<JSONObject> getAllByTableName(String tableName) {
        List<String> tNameList = new ArrayList<>();
        tNameList.add("book");
        if (tNameList.contains(tableName)) {
            try {
                return baseDaoImpl.getAllByTableName(tableName);
            } catch (Exception e) {
                e.printStackTrace();
                return new ArrayList<>();
            }
        } else {
            return new ArrayList<>();
        }
    }
}
